package com.qy.StudentInfo.handler;

import com.qy.StudentInfo.mapper.GradeMapper;
import com.qy.StudentInfo.pojo.Grade;
import com.qy.StudentInfo.pojo.SendEmailReq;
import com.qy.StudentInfo.service.MailService;
import com.qy.StudentInfo.utils.CommonUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: 实现发送邮件控制功能
 * @author: QiYue
 * @create: 20220429 14:51
 **/

@Controller
public class MailHandler {
    static Logger log = Logger.getLogger(MailHandler.class);
    private CommonUtil commonUtil;
    @Autowired
    public void setCommonUtil(CommonUtil commonUtil) {
        this.commonUtil = commonUtil;
    }

    @Autowired
    private MailService mailService;
    @RequestMapping("/sendStudentEmail")
    public String toSendEmail(SendEmailReq req){
//        log.info("邮件发送接口请求参数："+req);
        System.out.println("邮件发送接口请求参数"+req);

        mailService.sendMail(req);
        return "delsuccess";
    }

    /**
     * 发送教师邮件
     * @param req
     * @return
     */
    @RequestMapping("/sendTeacherEmail")
    public String toSendTeacherEmail(SendEmailReq req){
//        log.info("邮件发送接口请求参数："+req);
        System.out.println("邮件发送接口请求参数"+req);

        mailService.sendTeacherMail(req);
        return "delsuccess";
    }
}
